exports.checkUsername = function(req, res, callback) {
    if (req.session.username) {
        callback(req.session.username)
    } else {
        res.send(`<script>alert('你登录已经失效,请重新登录');location.href='/login'</script>`)
    }
}


exports.timeFormat = function(time) {


    var value = new Date(time)
    var year = value.getFullYear()
    var month = value.getMonth() + 1;
    var day = value.getDate()
    var hour = value.getHours()
    var min = value.getMinutes()
    var sec = value.getSeconds();

    return `${year}-${month}-${day} ${hour}:${min}:${sec}`

}